<!DOCTYPE html>
<html>
<header>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>

  <!-- 微信 JS-SDK 如果不需要兼容小程序，则无需引用此 JS 文件。 -->
  <!-- <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
  <script>
    ((e, n) => {
      "function" == typeof define && (define.amd || define.cmd) ? define(function () {
        return n(e)
      }) : n(e, !0)
    })(this, function (r, e) {
      var a, c, n, i, t, o, s, d, l, u, p, f, m, g, h, S, y, I, v, _, w, T;
      if (!r.jWeixin) return a = {
        config: "preVerifyJSAPI",
        onMenuShareTimeline: "menu:share:timeline",
        onMenuShareAppMessage: "menu:share:appmessage",
        onMenuShareQQ: "menu:share:qq",
        onMenuShareWeibo: "menu:share:weiboApp",
        onMenuShareQZone: "menu:share:QZone",
        previewImage: "imagePreview",
        getLocation: "geoLocation",
        openProductSpecificView: "openProductViewWithPid",
        addCard: "batchAddCard",
        openCard: "batchViewCard",
        chooseWXPay: "getBrandWCPayRequest",
        openEnterpriseRedPacket: "getRecevieBizHongBaoRequest",
        startSearchBeacons: "startMonitoringBeacons",
        stopSearchBeacons: "stopMonitoringBeacons",
        onSearchBeacons: "onBeaconsInRange",
        consumeAndShareCard: "consumedShareCard",
        openAddress: "editAddress"
      }, c = (() => {
        var e, n = {};
        for (e in a) n[a[e]] = e;
        return n
      })(), i = (n = r.document).title, t = navigator.userAgent.toLowerCase(), f = navigator.platform
        .toLowerCase(), o = !(!f.match("mac") && !f.match("win")), s = -1 != t.indexOf("wxdebugger"), d = -
        1 != t.indexOf("micromessenger"), l = -1 != t.indexOf("android"), u = -1 != t.indexOf("iphone") || -
        1 != t.indexOf("ipad"), p = (f = t.match(/micromessenger\/(\d+\.\d+\.\d+)/) || t.match(
          /micromessenger\/(\d+\.\d+)/)) ? f[1] : "", m = {
            initStartTime: L(),
            initEndTime: 0,
            preVerifyStartTime: 0,
            preVerifyEndTime: 0
          }, g = {
            version: 1,
            appId: "",
            initTime: 0,
            preVerifyTime: 0,
            networkType: "",
            isPreVerifyOk: 1,
            systemType: u ? 1 : l ? 2 : -1,
            clientVersion: p,
            url: encodeURIComponent(location.href)
          }, h = {}, S = {
            _completes: []
          }, y = {
            state: 0,
            data: {}
          }, O(function () {
            m.initEndTime = L()
          }), I = !1, v = [], _ = {
            config: function (e) {
              C("config", h = e);
              var o = !1 !== h.check;
              O(function () {
                if (o) k(a.config, {
                  verifyJsApiList: A(h.jsApiList),
                  verifyOpenTagList: A(h.openTagList)
                }, (S._complete = function (e) {
                  m.preVerifyEndTime = L(), y.state = 1, y.data = e
                }, S.success = function (e) {
                  g.isPreVerifyOk = 0
                }, S.fail = function (e) {
                  S._fail ? S._fail(e) : y.state = -1
                }, (t = S._completes).push(function () {
                  B()
                }), S.complete = function (e) {
                  for (var n = 0, i = t.length; n < i; ++n) t[n]();
                  S._completes = []
                }, S)), m.preVerifyStartTime = L();
                else {
                  y.state = 1;
                  for (var e = S._completes, n = 0, i = e.length; n < i; ++n) e[n]();
                  S._completes = []
                }
                var t
              }), _.invoke || (_.invoke = function (e, n, i) {
                r.WeixinJSBridge && WeixinJSBridge.invoke(e, P(n), i)
              }, _.on = function (e, n) {
                r.WeixinJSBridge && WeixinJSBridge.on(e, n)
              })
            },
            ready: function (e) {
              (0 != y.state || (S._completes.push(e), !d && h.debug)) && e()
            },
            error: function (e) {
              p < "6.0.2" || (-1 == y.state ? e(y.data) : S._fail = e)
            },
            checkJsApi: function (e) {
              k("checkJsApi", {
                jsApiList: A(e.jsApiList)
              }, (e._complete = function (e) {
                l && (i = e.checkResult) && (e.checkResult = JSON.parse(i));
                var n, i = e,
                  t = i.checkResult;
                for (n in t) {
                  var o = c[n];
                  o && (t[o] = t[n], delete t[n])
                }
              }, e))
            },
            onMenuShareTimeline: function (e) {
              M(a.onMenuShareTimeline, {
                complete: function () {
                  k("shareTimeline", {
                    title: e.title || i,
                    desc: e.title || i,
                    img_url: e.imgUrl || "",
                    link: e.link || location.href,
                    type: e.type || "link",
                    data_url: e.dataUrl || ""
                  }, e)
                }
              }, e)
            },
            onMenuShareAppMessage: function (n) {
              M(a.onMenuShareAppMessage, {
                complete: function (e) {
                  "favorite" === e.scene ? k("sendAppMessage", {
                    title: n.title || i,
                    desc: n.desc || "",
                    link: n.link || location.href,
                    img_url: n.imgUrl || "",
                    type: n.type || "link",
                    data_url: n.dataUrl || ""
                  }) : k("sendAppMessage", {
                    title: n.title || i,
                    desc: n.desc || "",
                    link: n.link || location.href,
                    img_url: n.imgUrl || "",
                    type: n.type || "link",
                    data_url: n.dataUrl || ""
                  }, n)
                }
              }, n)
            },
            onMenuShareQQ: function (e) {
              M(a.onMenuShareQQ, {
                complete: function () {
                  k("shareQQ", {
                    title: e.title || i,
                    desc: e.desc || "",
                    img_url: e.imgUrl || "",
                    link: e.link || location.href
                  }, e)
                }
              }, e)
            },
            onMenuShareWeibo: function (e) {
              M(a.onMenuShareWeibo, {
                complete: function () {
                  k("shareWeiboApp", {
                    title: e.title || i,
                    desc: e.desc || "",
                    img_url: e.imgUrl || "",
                    link: e.link || location.href
                  }, e)
                }
              }, e)
            },
            onMenuShareQZone: function (e) {
              M(a.onMenuShareQZone, {
                complete: function () {
                  k("shareQZone", {
                    title: e.title || i,
                    desc: e.desc || "",
                    img_url: e.imgUrl || "",
                    link: e.link || location.href
                  }, e)
                }
              }, e)
            },
            updateTimelineShareData: function (e) {
              k("updateTimelineShareData", {
                title: e.title,
                link: e.link,
                imgUrl: e.imgUrl
              }, e)
            },
            updateAppMessageShareData: function (e) {
              k("updateAppMessageShareData", {
                title: e.title,
                desc: e.desc,
                link: e.link,
                imgUrl: e.imgUrl
              }, e)
            },
            startRecord: function (e) {
              k("startRecord", {}, e)
            },
            stopRecord: function (e) {
              k("stopRecord", {}, e)
            },
            onVoiceRecordEnd: function (e) {
              M("onVoiceRecordEnd", e)
            },
            playVoice: function (e) {
              k("playVoice", {
                localId: e.localId
              }, e)
            },
            pauseVoice: function (e) {
              k("pauseVoice", {
                localId: e.localId
              }, e)
            },
            stopVoice: function (e) {
              k("stopVoice", {
                localId: e.localId
              }, e)
            },
            onVoicePlayEnd: function (e) {
              M("onVoicePlayEnd", e)
            },
            uploadVoice: function (e) {
              k("uploadVoice", {
                localId: e.localId,
                isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
              }, e)
            },
            downloadVoice: function (e) {
              k("downloadVoice", {
                serverId: e.serverId,
                isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
              }, e)
            },
            translateVoice: function (e) {
              k("translateVoice", {
                localId: e.localId,
                isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
              }, e)
            },
            chooseImage: function (e) {
              k("chooseImage", {
                scene: "1|2",
                count: e.count || 9,
                sizeType: e.sizeType || ["original", "compressed"],
                sourceType: e.sourceType || ["album", "camera"]
              }, (e._complete = function (e) {
                if (l) {
                  var n = e.localIds;
                  try {
                    n && (e.localIds = JSON.parse(n))
                  } catch (e) { }
                }
              }, e))
            },
            getLocation: function (e) { },
            getLocation: function (e) {
              e = e || {}, k(a.getLocation, {
                type: e.type || "wgs84"
              }, (e._complete = function (e) {
                delete e.type
              }, e))
            },
            previewImage: function (e) {
              k(a.previewImage, {
                current: e.current,
                urls: e.urls
              }, e)
            },
            uploadImage: function (e) {
              k("uploadImage", {
                localId: e.localId,
                isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
              }, e)
            },
            downloadImage: function (e) {
              k("downloadImage", {
                serverId: e.serverId,
                isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
              }, e)
            },
            getLocalImgData: function (e) {
              !1 === I ? (I = !0, k("getLocalImgData", {
                localId: e.localId
              }, (e._complete = function (e) {
                var n;
                I = !1, 0 < v.length && (n = v.shift(), wx.getLocalImgData(n))
              }, e))) : v.push(e)
            },
            getNetworkType: function (e) {
              k("getNetworkType", {}, (e._complete = function (e) {
                var n = e,
                  e = n.errMsg,
                  i = (n.errMsg = "getNetworkType:ok", n.subtype);
                if (delete n.subtype, i) n.networkType = i;
                else {
                  var i = e.indexOf(":"),
                    t = e.substring(i + 1);
                  switch (t) {
                    case "wifi":
                    case "edge":
                    case "wwan":
                      n.networkType = t;
                      break;
                    default:
                      n.errMsg = "getNetworkType:fail"
                  }
                }
              }, e))
            },
            openLocation: function (e) {
              k("openLocation", {
                latitude: e.latitude,
                longitude: e.longitude,
                name: e.name || "",
                address: e.address || "",
                scale: e.scale || 28,
                infoUrl: e.infoUrl || ""
              }, e)
            },
            hideOptionMenu: function (e) {
              k("hideOptionMenu", {}, e)
            },
            showOptionMenu: function (e) {
              k("showOptionMenu", {}, e)
            },
            closeWindow: function (e) {
              k("closeWindow", {}, e = e || {})
            },
            hideMenuItems: function (e) {
              k("hideMenuItems", {
                menuList: e.menuList
              }, e)
            },
            showMenuItems: function (e) {
              k("showMenuItems", {
                menuList: e.menuList
              }, e)
            },
            hideAllNonBaseMenuItem: function (e) {
              k("hideAllNonBaseMenuItem", {}, e)
            },
            showAllNonBaseMenuItem: function (e) {
              k("showAllNonBaseMenuItem", {}, e)
            },
            scanQRCode: function (e) {
              k("scanQRCode", {
                needResult: (e = e || {}).needResult || 0,
                scanType: e.scanType || ["qrCode", "barCode"]
              }, (e._complete = function (e) {
                var n;
                u && (n = e.resultStr) && (n = JSON.parse(n), e.resultStr = n && n
                  .scan_code && n.scan_code.scan_result)
              }, e))
            },
            openAddress: function (e) {
              k(a.openAddress, {}, (e._complete = function (e) {
                (e = e).postalCode = e.addressPostalCode, delete e.addressPostalCode, e
                  .provinceName = e.proviceFirstStageName, delete e
                    .proviceFirstStageName, e.cityName = e.addressCitySecondStageName,
                  delete e.addressCitySecondStageName, e.countryName = e
                    .addressCountiesThirdStageName, delete e
                      .addressCountiesThirdStageName, e.detailInfo = e.addressDetailInfo,
                  delete e.addressDetailInfo
              }, e))
            },
            openProductSpecificView: function (e) {
              k(a.openProductSpecificView, {
                pid: e.productId,
                view_type: e.viewType || 0,
                ext_info: e.extInfo
              }, e)
            },
            addCard: function (e) {
              for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) {
                var r = n[t],
                  r = {
                    card_id: r.cardId,
                    card_ext: r.cardExt
                  };
                i.push(r)
              }
              k(a.addCard, {
                card_list: i
              }, (e._complete = function (e) {
                if (n = e.card_list) {
                  for (var n, i = 0, t = (n = JSON.parse(n)).length; i < t; ++i) {
                    var o = n[i];
                    o.cardId = o.card_id, o.cardExt = o.card_ext, o.isSuccess = !!o
                      .is_succ, delete o.card_id, delete o.card_ext, delete o
                        .is_succ
                  }
                  e.cardList = n, delete e.card_list
                }
              }, e))
            },
            chooseCard: function (e) {
              k("chooseCard", {
                app_id: h.appId,
                location_id: e.shopId || "",
                sign_type: e.signType || "SHA1",
                card_id: e.cardId || "",
                card_type: e.cardType || "",
                card_sign: e.cardSign,
                time_stamp: e.timestamp + "",
                nonce_str: e.nonceStr
              }, (e._complete = function (e) {
                e.cardList = e.choose_card_info, delete e.choose_card_info
              }, e))
            },
            openCard: function (e) {
              for (var n = e.cardList, i = [], t = 0, o = n.length; t < o; ++t) {
                var r = n[t],
                  r = {
                    card_id: r.cardId,
                    code: r.code
                  };
                i.push(r)
              }
              k(a.openCard, {
                card_list: i
              }, e)
            },
            consumeAndShareCard: function (e) {
              k(a.consumeAndShareCard, {
                consumedCardId: e.cardId,
                consumedCode: e.code
              }, e)
            },
            chooseWXPay: function (e) {
              k(a.chooseWXPay, x(e), e), B({
                jsApiName: "chooseWXPay"
              })
            },
            openEnterpriseRedPacket: function (e) {
              k(a.openEnterpriseRedPacket, x(e), e)
            },
            startSearchBeacons: function (e) {
              k(a.startSearchBeacons, {
                ticket: e.ticket
              }, e)
            },
            stopSearchBeacons: function (e) {
              k(a.stopSearchBeacons, {}, e)
            },
            onSearchBeacons: function (e) {
              M(a.onSearchBeacons, e)
            },
            openEnterpriseChat: function (e) {
              k("openEnterpriseChat", {
                useridlist: e.userIds,
                chatname: e.groupName
              }, e)
            },
            launchMiniProgram: function (e) {
              k("launchMiniProgram", {
                targetAppId: e.targetAppId,
                path: (e => {
                  var n;
                  if ("string" == typeof e && 0 < e.length) return n = e.split(
                    "?")[0], n += ".html", void 0 !== (e = e.split("?")[
                      1]) ?
                      n + "?" + e : n
                })(e.path),
                envVersion: e.envVersion
              }, e)
            },
            openBusinessView: function (e) {
              k("openBusinessView", {
                businessType: e.businessType,
                queryString: e.queryString || "",
                envVersion: e.envVersion
              }, (e._complete = function (n) {
                if (l) {
                  var e = n.extraData;
                  if (e) try {
                    n.extraData = JSON.parse(e)
                  } catch (e) {
                    n.extraData = {}
                  }
                }
              }, e))
            },
            miniProgram: {
              navigateBack: function (e) {
                e = e || {}, O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "navigateBack",
                    arg: {
                      delta: e.delta || 1
                    }
                  }, e)
                })
              },
              navigateTo: function (e) {
                O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "navigateTo",
                    arg: {
                      url: e.url
                    }
                  }, e)
                })
              },
              redirectTo: function (e) {
                O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "redirectTo",
                    arg: {
                      url: e.url
                    }
                  }, e)
                })
              },
              switchTab: function (e) {
                O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "switchTab",
                    arg: {
                      url: e.url
                    }
                  }, e)
                })
              },
              reLaunch: function (e) {
                O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "reLaunch",
                    arg: {
                      url: e.url
                    }
                  }, e)
                })
              },
              postMessage: function (e) {
                O(function () {
                  k("invokeMiniProgramAPI", {
                    name: "postMessage",
                    arg: e.data || {}
                  }, e)
                })
              },
              getEnv: function (e) {
                O(function () {
                  e({
                    miniprogram: "miniprogram" === r.__wxjs_environment
                  })
                })
              }
            }
          }, w = 1, T = {}, n.addEventListener("error", function (e) {
            var n, i, t;
            l || (t = (n = e.target).tagName, i = n.src, "IMG" != t && "VIDEO" != t && "AUDIO" != t &&
              "SOURCE" != t) || -1 != i.indexOf("wxlocalresource://") && (e.preventDefault(), e
                .stopPropagation(), (t = n["wx-id"]) || (t = w++, n["wx-id"] = t), T[t] || (T[t] = !
                  0, wx.ready(function () {
                    wx.getLocalImgData({
                      localId: i,
                      success: function (e) {
                        n.src = e.localData
                      }
                    })
                  })))
          }, !0), n.addEventListener("load", function (e) {
            var n;
            l || (n = (e = e.target).tagName, "IMG" != n && "VIDEO" != n && "AUDIO" != n && "SOURCE" !=
              n) || (n = e["wx-id"]) && (T[n] = !1)
          }, !0), e && (r.wx = r.jWeixin = _), _;

      function k (n, e, i) {
        r.WeixinJSBridge ? WeixinJSBridge.invoke(n, P(e), function (e) {
          V(n, e, i)
        }) : C(n, i)
      }

      function M (n, i, t) {
        r.WeixinJSBridge ? WeixinJSBridge.on(n, function (e) {
          t && t.trigger && t.trigger(e), V(n, e, i)
        }) : C(n, t || i)
      }

      function P (e) {
        return (e = e || {}).appId = h.appId, e.verifyAppId = h.appId, e.verifySignType = "sha1", e
          .verifyTimestamp = h.timestamp + "", e.verifyNonceStr = h.nonceStr, e.verifySignature = h.signature,
          e
      }

      function x (e) {
        return {
          timeStamp: e.timestamp + "",
          nonceStr: e.nonceStr,
          package: e.package,
          paySign: e.paySign,
          signType: e.signType || "SHA1"
        }
      }

      function V (e, n, i) {
        "openEnterpriseChat" != e && "openBusinessView" !== e || (n.errCode = n.err_code), delete n.err_code,
          delete n.err_desc, delete n.err_detail;
        var t = n.errMsg,
          e = (t || (t = n.err_msg, delete n.err_msg, t = ((e, n) => {
            var i, t = c[e];
            return t && (e = t), t = "ok", n && (i = n.indexOf(":"), "access denied" != (t = (t =
              (t = -1 != (t = -1 != (t = "failed" == (t = "confirm" == (t = n
                .substring(i + 1)) ? "ok" : t) ? "fail" : t).indexOf(
                  "failed_") ? t.substring(7) : t).indexOf("fail_") ? t
                    .substring(5) : t).replace(/_/g, " ")).toLowerCase()) &&
              "no permission to execute" != t || (t = "permission denied"), "" == (t =
                "config" == e && "function not exist" == t ? "ok" : t)) && (t = "fail"),
              n = e + ":" + t
          })(e, t), n.errMsg = t), (i = i || {})._complete && (i._complete(n), delete i._complete), t = n
            .errMsg || "", h.debug && !i.isInnerInvoke && alert(JSON.stringify(n)), t.indexOf(":"));
        switch (t.substring(e + 1)) {
          case "ok":
            i.success && i.success(n);
            break;
          case "cancel":
            i.cancel && i.cancel(n);
            break;
          default:
            i.fail && i.fail(n)
        }
        i.complete && i.complete(n)
      }

      function A (e) {
        if (e) {
          for (var n = 0, i = e.length; n < i; ++n) {
            var t = e[n],
              t = a[t];
            t && (e[n] = t)
          }
          return e
        }
      }

      function C (e, n) {
        var i;
        !h.debug || n && n.isInnerInvoke || ((i = c[e]) && (e = i), n && n._complete && delete n._complete,
          console.log('"' + e + '",', n || ""))
      }

      function B (n) {
        var i;
        o || s || h.debug || p < "6.0.2" || g.systemType < 0 || (i = new Image, g.appId = h.appId, g.initTime = m
          .initEndTime - m.initStartTime, g.preVerifyTime = m.preVerifyEndTime - m.preVerifyStartTime, _
            .getNetworkType({
              isInnerInvoke: !0,
              success: function (e) {
                g.networkType = e.networkType;
                e = "https://open.weixin.qq.com/sdk/report?v=" + g.version + "&o=" + g
                  .isPreVerifyOk + "&s=" + g.systemType + "&c=" + g.clientVersion + "&a=" + g
                    .appId + "&n=" + g.networkType + "&i=" + g.initTime + "&p=" + g
                    .preVerifyTime + "&u=" + g.url + "&jsapi_name=" + (n ? n.jsApiName : "");
                i.src = e
              }
            }))
      }

      function L () {
        return (new Date).getTime()
      }

      function O (e) {
        d && (r.WeixinJSBridge ? e() : n.addEventListener && n.addEventListener("WeixinJSBridgeReady", e, !1))
      }
    });
  </script>
  <!-- uni 的 SDK，必须引用。 -->
  <!-- <script type="text/javascript" src="https://gitcode.net/dcloud/uni-app/-/raw/dev/dist/uni.webview.1.5.6.js"></script> -->
  <script>
    ! function (e, n) {
      "object" == typeof exports && "undefined" != typeof module ? module.exports = n() : "function" ==
        typeof define && define.amd ? define(n) : (e = e || self).uni = n()
    }(this, (function () {
      "use strict";
      try {
        var e = {};
        Object.defineProperty(e, "passive", {
          get: function () {
            !0
          }
        }), window.addEventListener("test-passive", null, e)
      } catch (e) { }
      var n = Object.prototype.hasOwnProperty;

      function i (e, i) {
        return n.call(e, i)
      }
      var t = [];

      function o () {
        return window.__dcloud_weex_postMessage || window.__dcloud_weex_
      }

      function a () {
        return window.__uniapp_x_postMessage || window.__uniapp_x_
      }
      var r = function (e, n) {
        var i = {
          options: {
            timestamp: +new Date
          },
          name: e,
          arg: n
        };
        if (a()) {
          if ("postMessage" === e) {
            var r = {
              data: n
            };
            return window.__uniapp_x_postMessage ? window.__uniapp_x_postMessage(r) : window
              .__uniapp_x_.postMessage(JSON.stringify(r))
          }
          var d = {
            type: "WEB_INVOKE_APPSERVICE",
            args: {
              data: i,
              webviewIds: t
            }
          };
          window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(d) : window
            .__uniapp_x_.postMessageToService(JSON.stringify(d))
        } else if (o()) {
          if ("postMessage" === e) {
            var s = {
              data: [n]
            };
            return window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessage(s) : window
              .__dcloud_weex_.postMessage(JSON.stringify(s))
          }
          var w = {
            type: "WEB_INVOKE_APPSERVICE",
            args: {
              data: i,
              webviewIds: t
            }
          };
          window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(w) : window
            .__dcloud_weex_.postMessageToService(JSON.stringify(w))
        } else {
          if (!window.plus) return window.parent.postMessage({
            type: "WEB_INVOKE_APPSERVICE",
            data: i,
            pageId: ""
          }, "*");
          if (0 === t.length) {
            var u = plus.webview.currentWebview();
            if (!u) throw new Error("plus.webview.currentWebview() is undefined");
            var g = u.parent(),
              v = "";
            v = g ? g.id : u.id, t.push(v)
          }
          if (plus.webview.getWebviewById("__uniapp__service")) plus.webview.postMessageToUniNView({
            type: "WEB_INVOKE_APPSERVICE",
            args: {
              data: i,
              webviewIds: t
            }
          }, "__uniapp__service");
          else {
            var c = JSON.stringify(i);
            plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat(
              "WEB_INVOKE_APPSERVICE", '",').concat(c, ",").concat(JSON.stringify(t),
                ");"))
          }
        }
      },
        d = {
          navigateTo: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
              n = e.url;
            r("navigateTo", {
              url: encodeURI(n)
            })
          },
          navigateBack: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
              n = e.delta;
            r("navigateBack", {
              delta: parseInt(n) || 1
            })
          },
          switchTab: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
              n = e.url;
            r("switchTab", {
              url: encodeURI(n)
            })
          },
          reLaunch: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
              n = e.url;
            r("reLaunch", {
              url: encodeURI(n)
            })
          },
          redirectTo: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
              n = e.url;
            r("redirectTo", {
              url: encodeURI(n)
            })
          },
          getEnv: function (e) {
            a() ? e({
              uvue: !0
            }) : o() ? e({
              nvue: !0
            }) : window.plus ? e({
              plus: !0
            }) : e({
              h5: !0
            })
          },
          postMessage: function () {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            r("postMessage", e.data || {})
          }
        },
        s = /uni-app/i.test(navigator.userAgent),
        w = /Html5Plus/i.test(navigator.userAgent),
        u = /complete|loaded|interactive/;
      var g = window.my && navigator.userAgent.indexOf(["t", "n", "e", "i", "l", "C", "y", "a", "p", "i", "l",
        "A"
      ].reverse().join("")) > -1;
      var v = window.swan && window.swan.webView && /swan/i.test(navigator.userAgent);
      var c = window.qq && window.qq.miniProgram && /QQ/i.test(navigator.userAgent) && /miniProgram/i.test(
        navigator.userAgent);
      var p = window.tt && window.tt.miniProgram && /toutiaomicroapp/i.test(navigator.userAgent);
      var _ = window.wx && window.wx.miniProgram && /micromessenger/i.test(navigator.userAgent) &&
        /miniProgram/i.test(navigator.userAgent);
      var m = window.qa && /quickapp/i.test(navigator.userAgent);
      var f = window.ks && window.ks.miniProgram && /micromessenger/i.test(navigator.userAgent) &&
        /miniProgram/i.test(navigator.userAgent);
      var l = window.tt && window.tt.miniProgram && /Lark|Feishu/i.test(navigator.userAgent);
      var E = window.jd && window.jd.miniProgram && /jdmp/i.test(navigator.userAgent);
      var x = window.xhs && window.xhs.miniProgram && /xhsminiapp/i.test(navigator.userAgent);
      for (var S, h = function () {
        window.UniAppJSBridge = !0, document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady", {
          bubbles: !0,
          cancelable: !0
        }))
      }, y = [function (e) {
        if (s || w) return window.__uniapp_x_postMessage || window.__uniapp_x_ || window
          .__dcloud_weex_postMessage || window.__dcloud_weex_ ? document.addEventListener(
            "DOMContentLoaded", e) : window.plus && u.test(document.readyState) ?
          setTimeout(e, 0) : document.addEventListener("plusready", e), d
      }, function (e) {
        if (_) return window.WeixinJSBridge && window.WeixinJSBridge.invoke ? setTimeout(e, 0) :
          document.addEventListener("WeixinJSBridgeReady", e), window.wx.miniProgram
      }, function (e) {
        if (c) return window.QQJSBridge && window.QQJSBridge.invoke ? setTimeout(e, 0) : document
          .addEventListener("QQJSBridgeReady", e), window.qq.miniProgram
      }, function (e) {
        if (g) {
          document.addEventListener("DOMContentLoaded", e);
          var n = window.my;
          return {
            navigateTo: n.navigateTo,
            navigateBack: n.navigateBack,
            switchTab: n.switchTab,
            reLaunch: n.reLaunch,
            redirectTo: n.redirectTo,
            postMessage: n.postMessage,
            getEnv: n.getEnv
          }
        }
      }, function (e) {
        if (v) return document.addEventListener("DOMContentLoaded", e), window.swan.webView
      }, function (e) {
        if (p) return document.addEventListener("DOMContentLoaded", e), window.tt.miniProgram
      }, function (e) {
        if (m) {
          window.QaJSBridge && window.QaJSBridge.invoke ? setTimeout(e, 0) : document
            .addEventListener("QaJSBridgeReady", e);
          var n = window.qa;
          return {
            navigateTo: n.navigateTo,
            navigateBack: n.navigateBack,
            switchTab: n.switchTab,
            reLaunch: n.reLaunch,
            redirectTo: n.redirectTo,
            postMessage: n.postMessage,
            getEnv: n.getEnv
          }
        }
      }, function (e) {
        if (f) return window.WeixinJSBridge && window.WeixinJSBridge.invoke ? setTimeout(e, 0) :
          document.addEventListener("WeixinJSBridgeReady", e), window.ks.miniProgram
      }, function (e) {
        if (l) return document.addEventListener("DOMContentLoaded", e), window.tt.miniProgram
      }, function (e) {
        if (E) return window.JDJSBridgeReady && window.JDJSBridgeReady.invoke ? setTimeout(e,
          0) : document.addEventListener("JDJSBridgeReady", e), window.jd.miniProgram
      }, function (e) {
        if (x) return window.xhs.miniProgram
      }, function (e) {
        return document.addEventListener("DOMContentLoaded", e), d
      }], M = 0; M < y.length && !(S = y[M](h)); M++);
      S || (S = {});
      var P = "undefined" != typeof uni ? uni : {};
      if (!P.navigateTo)
        for (var b in S) i(S, b) && (P[b] = S[b]);
      return P.webView = S, P
    }));
  </script>
  <style>
    @keyframes animate {
      0% {
        color: #ccc;
      }

      100% {
        color: transparent;
      }
    }

    * {
      padding: 0;
      margin: 0;
    }

    ::-webkit-media-controls {
      display: none !important;
    }

    html,
    body {
      width: 100%;
      height: 100%;
      font-size: 16rem;
    }

    video {
      width: 100%;
      height: 100%;
      font-size: 0;
      /* object-fit: cover; */
    }

    canvas {
      position: fixed;
      bottom: 0;
      visibility: hidden;
    }

    select {
      position: fixed;
      bottom: 40rem;
      z-index: 9;
      width: 100px;
      text-align: center;
    }

    .bg {
      background-color: rgba(0, 0, 0, .35);
      color: #fff;
    }

    .flex-row-center {
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .handle-colse {
      position: absolute;
      right: 20rem;
      top: 40rem;
      font-size: 60rem;
      color: #fff;
    }


    .camera {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background-color: #fff;
      overflow: hidden;

      video {
        position: relative;
        z-index: 1;
      }
    }

    .camera-tips {
      font-size: 26rem;
      color: #ccc;
      animation: animate 2s linear infinite;
    }

    .cameraMode {
      position: relative;
      width: 100%;
      height: 100%;
    }

    .box-border {
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      box-sizing: content-box;
    }

    .box-border .box-border-item.box-border-mini {
      width: 25rem;
      height: 25rem;
    }

    .box-border .border-l {
      width: 50rem;
      height: 50rem;
      position: absolute;
      left: 0;
      top: 0;
      border-width: 2rem 0 0 2rem;
      border-style: solid;
      border-color: #4d85ff;
    }

    .box-border .border-t {
      width: 50rem;
      height: 50rem;
      position: absolute;
      top: 0;
      right: 0;
      border-width: 2rem 2rem 0 0;
      border-style: solid;
      border-color: #4d85ff;
    }

    .box-border .border-r {
      width: 50rem;
      height: 50rem;
      position: absolute;
      right: 0;
      bottom: 0;
      border-width: 0 2rem 2rem 0;
      border-style: solid;
      border-color: #4d85ff;
    }

    .box-border .border-b {
      width: 50rem;
      height: 50rem;
      position: absolute;
      left: 0;
      bottom: 0;
      border-width: 0 0 2rem 2rem;
      border-style: solid;
      border-color: #4d85ff;
    }

    .camera-layer {
      display: flex;
      flex-direction: column;
      position: absolute;
      width: 100%;
      height: 100%;
      z-index: 2;
    }

    .camera-layer .camera-view-header {
      width: 100%;
      height: calc((100vh - 250rem) / 2);
    }

    .camera-layer .camera-view-body {
      position: relative;
      width: 100%;
      height: 250rem;
      display: flex;
    }

    .camera-layer .camera-view-body .camera-body-left {
      width: 250rem;
      height: 250rem;
    }

    .camera-layer .camera-view-body .camera-body {
      position: relative;
      width: 250rem;
      height: 250rem;
      display: flex;
      flex-direction: column;
    }

    .camera-layer .camera-view-body .camera-body .assist-name {
      width: 100%;
      height: 50rem;
      position: absolute;
      top: -50rem;
    }

    .camera-layer .camera-view-body .camera-body .assist-name .assist-block-bottom {
      width: 100%;
      height: 50rem;
      font-size: 26rem;
      line-height: 50rem;
      text-align: center;
      color: #fff;
    }

    .camera-layer .camera-view-body .camera-body .assist-code {
      position: relative;
      width: 250rem;
      height: 250rem;
    }

    .camera-layer .camera-view-body .camera-body-right {
      width: 250rem;
      height: 250rem;
    }

    .camera-layer .camera-view-footer {
      height: calc((100vh - 250rem) / 2);
    }
  </style>
</header>

<body>
  <div class="camera">
    <div class="camera-layer">
      <!-- top -->
      <div class="camera-view-header  bg flex-row-center">
        <!-- 提示 -->
        <div class="camera-tips"></div>
      </div>
      <!-- center -->
      <div class="camera-view-body">
        <div class="camera-body-left bg"> </div>
        <div class="camera-body">
          <!-- <div class="line">请按照辅助线对准文字</div> -->

          <!-- 标志 -->
          <div class="assist-name">
            <div class="assist-block-bottom"> 请对准要识别的标签 </div>
          </div>
          <!-- 码图 -->
          <div class="assist-code">
            <div class="box-border">
              <div class="border-l"> </div>
              <div class="border-t"> </div>
              <div class="border-r"> </div>
              <div class="border-b"> </div>
            </div>
          </div>
        </div>
        <div class="camera-body-right bg">

        </div>
      </div>
      <!-- bottom -->
      <div class="camera-view-footer flex-row-center bg"> </div>
    </div>

    <!-- 关闭 -->
    <div v-if="close" class="handle-colse iconfont icon-close" @click="handleClose"></div>
    <!-- 相机 -->
    <video id="video" muted autoplay playsinline webkit-playsinline x5-video-player-type="h5"
      x5-video-player-fullscreen="true" style="display: none;"></video>


  </div>
  <!-- 画布 -->
  <canvas id="canvas"></canvas>
  <!-- 切换摄像头 -->
  <!-- <select id="select"></select> -->
  <!-- 下载 -->
  <a id="download"></a>
</body>

<script>


  // 设置根字体大小（通常在页面初始化时执行）
  const docEl = document.documentElement;
  const resize = () => {
    const clientWidth = docEl.clientWidth || 375;
    docEl.style.fontSize = clientWidth / 750 + 'px'; // 750rrem = 100%宽度
  };
  window.addEventListener('resize', resize);
  resize();

  function downfile (blob) {
    if (window.navigator.msSaveOrOpenBlob) {
      navigator.msSaveBlob(blob, 'image.png');
    } else {
      var link = document.getElementById("download");

      link.href = window.URL.createObjectURL(blob);
      link.download = 'image.png';

      // fix Firefox
      link.style.display = "none";

      link.click();

    }
  }

  function formatQuery (data) {
    return '?' + Object.keys(data).map(key => {
      return `${key}=${typeof data[key] == 'string' ? encodeURIComponent(data[key]) : data[key]}`
    }).join('&')
  }

  function getQuery () {

    const params = {};
    const queryString = window.location.search.substring(1);
    const pairs = queryString.split('&');

    for (let i = 0; i < pairs.length; i++) {
      const pair = pairs[i].split('=');
      params[pair[0]] = decodeURIComponent(pair[1] || '');
    }

    return params;
  }

  function throttle (fn, delay) {
    var timer;
    return function () {
      var _this = this;
      var args = arguments;
      if (timer) {
        return;
      }
      timer = setTimeout(function () {
        fn.apply(_this, args);
        timer = null; // 在delay后执行完fn之后清空timer，此时timer为假，throttle触发可以进入计时器
      }, delay)
    }
  }

  //地址参数
  const query = getQuery()
  const apis = {
    190: 'http://192.168.31.190:8000',
    187: 'http://192.168.31.187:8000',
  }
  const api = apis[query.api] || 'https://www.antifakefire.com:8040'
  if (apis[query.api]) {

    console.log('测试环境！')
    var vConsole = new window.VConsole();
  }

  function UploadCodeImage (blob) {
    return new Promise((resolve, reject) => {
      let data = new FormData()
      data.append('image', blob)
      fetch(api + '/api/watermark/android_qr/up_load', {
        method: 'POST',
        body: data
      }).then(res => resolve(res.json())).catch(err => {
        reject(err)
      })
    })
  }

  function RegisterCodeImage (blob, info) {
    return new Promise((resolve, reject) => {
      let data = new FormData()
      data.append('image', blob)
      data.append('body', info)
      fetch(api + '/api/watermark/register', {
        method: 'POST',
        body: data
      }).then(res => resolve(res.json())).catch(err => {
        reject(err)
      })
    })
  }

  function UploadDeviceInfo (devices) {

    const isSaved = localStorage.getItem('saveDevice')
    console.log('isSaved', isSaved);
    if (isSaved) return

    const fpPromise = import('https://openfpcdn.io/fingerprintjs/v4')
      .then(FingerprintJS => FingerprintJS.load())

    fpPromise
      .then(fp => fp.get())
      .then(result => {
        // This is the visitor identifier:
        const visitorId = result.visitorId

        const devicesInfo = {
          deviceId: visitorId,
          brand: navigator.userAgent.split(')')[0] + ')',
          model: '',
          cameras: devices.map(el => {
            const params = el.getCapabilities && el.getCapabilities() || {}
            return {
              cameraName: el.label,
              resolution: `${params.width && params.width.max || ''}*${params.height && params.height.max || ''}`,
              frameRate: params.frameRate && params.frameRate.max || '',
            }
          })
        }

        console.log('devicesInfo :', devicesInfo)
        let data = new FormData()
        data.append('body', JSON.stringify(devicesInfo));
        fetch(
          api + '/api/device/save', {
          method: 'POST',
          body: data
        }).then(() => {
          localStorage.setItem('saveDevice', true)
        })
      })
  }
</script>
<script>
  try {
    class MediaDevice {
      constructor(direction) {
        // 前后摄像头
        this.cameraDirection = direction || 'user' //user environment
        // 设备
        this.devices = []

      }
      async initDevice () {
        try {

          // 必须先获取一次摄像头权限
          const mainstream = await navigator.mediaDevices.getUserMedia({
            video: {
              facingMode: this.cameraDirection
            },
          });
          //清理轨道
          mainstream.getVideoTracks().forEach(el => {
            el.stop()
          });
          // 枚举设备
          const devices = await navigator.mediaDevices.enumerateDevices();

          // 过滤设备
          this.devices = devices.filter(el => el.kind === 'videoinput')
          // 上传
          UploadDeviceInfo(this.devices)

          console.log('devices: ', this.devices.map(el => el.label));
        } catch (error) {
          console.log('initDevice err: ', error);
        }
      }

    }

    class MediaGyro {
      constructor() {
        //是否支持
        this.support = true
        // 稳定持续时间
        this.stableDuration = 1000
        // 采样间隔(ms)
        this.sampleInterval = 100
        // 震动范围
        this.threshold = 3
        //标准事件
        this.callback = null
        //计数器
        this.count = 0
      }
      //初始化
      async initGyro (callback) {
        this.callback = callback

        // 1. 检测支持性
        if ('DeviceOrientationEvent' in window) {
          // 2. iOS 权限请求
          if (typeof DeviceOrientationEvent.requestPermission === 'function') {
            try {
              const permission = await DeviceOrientationEvent.requestPermission();
              if (permission !== 'granted') {
                this.support = false
                return;
              }
            } catch (error) {
              this.support = false
              console.error('error', error, error.message, error.name);
              return;
            }
          } else {
            this.support = false
          }
        }

        if (this.support) {
          this.startGyro()
        }
      }
      // 启动陀螺仪 
      async startGyro (callback) {
        try {
          const history = {
            time: null,
            alpha: 0,
            beta: 0,
            gamma: 0,
          }
          const maxCount = Math.ceil(this.stableDuration / this.sampleInterval)

          console.log('准备监听陀螺仪');
          window.addEventListener('deviceorientation', ({
            alpha,
            beta,
            gamma
          }) => {
            console.log('监听陀螺仪', history);

            if (history.time) {
              if (Date.now() - history.time < this.sampleInterval) return

              if (alpha - history.alpha <= this.threshold && beta - history.beta <= this
                .threshold &&
                gamma - history.gamma <= this.threshold) {
                this.count++
              }

              if (this.count == maxCount) {
                this.callback && this.callback()
                this.count = 0
              }

              history.time = Date.now()
              history.alpha = alpha.toFixed(4)
              history.beta = beta.toFixed(4)
              history.gamma = gamma.toFixed(4)

            } else {
              history.time = Date.now()
              history.alpha = alpha.toFixed(4)
              history.beta = beta.toFixed(4)
              history.gamma = gamma.toFixed(4)
            }
          })

        } catch (error) {
          console.error('陀螺仪获取失败:', error);
        }

      }
    }

    class MediaVideo {
      constructor(direction) {
        this.stream = null
        this.canvas = null
        this.width = null
        this.height = null
      }
      // 启动摄像头
      async startCamera (deviceId, option = {}) {
        try {
          const confireuse = {
            video: {
              ...option
            }
          }

          if (deviceId) {
            confireuse.video.deviceId = {
              exact: deviceId
            }
          }

          console.log('startCamera deviceId ', deviceId, confireuse);

          const stream = await navigator.mediaDevices.getUserMedia(confireuse);
          this.stream = stream
          return stream
        } catch (error) {
          console.error('摄像头切换失败:', error, error.message, error.constraint, error.name);
          return null
        }
      }
      // 停止摄像头
      stopCamera () {
        this.stream && this.stream.getTracks().forEach(track => track.stop());
        this.stream = null;
      }
      // 初始画布
      initCanvas (width, height) {
        const rem = width / 750
        const sizeWidth = 250 * rem

        let canvas = document.getElementById('canvas')
        if (!canvas) {
          canvas = document.createElement('canvas')
          canvas.id = 'canvas'
          // canvas.style.display = 'none'
          document.body.append(canvas)
        }
        canvas.width = sizeWidth
        canvas.height = sizeWidth


        this.width = width
        this.height = height
        this.canvas = canvas
      }
      // 拍照
      takeCamera (dom) {
        return new Promise((resolve, reject) => {
          if (this.stream && dom && dom.tagName === 'VIDEO') {
            const rem = this.width / 750
            const sizeWidth = 250 * rem
            const start_x = (this.width - sizeWidth) / 2
            const start_y = (this.height - sizeWidth) / 2

            this.canvas.getContext('2d').drawImage(dom, start_x, start_y, sizeWidth,
              sizeWidth, 0,
              0,
              sizeWidth, sizeWidth);

            console.log('拍照成功！', this.width, this.height, rem, sizeWidth, start_x, start_y);

            this.canvas.toBlob((blob) => {
              resolve(blob)
            })
          } else {
            return reject('拍照失败，画布不存在！')
          }
        })
      }
    }

    document.addEventListener('UniAppJSBridgeReady', async function () {
      uni.getEnv(function (res) {
        if (res.plus) {
          console.log('当前环境为【5+App】');
        } else if (res.miniprogram) {
          console.log('当前环境为【微信小程序】');
        }
      });

      try {
        const deviceClass = new MediaDevice('environment')
        console.log('deviceClass', deviceClass);

        const gyroClass = new MediaGyro()
        console.log('gyroClass', gyroClass);

        const videoClass = new MediaVideo()
        console.log('videoClass', videoClass);


        const video = document.getElementById('video');
        // const select = document.getElementById('select');
        const tips = document.querySelector('.camera-tips');

        const width = document.documentElement.clientWidth
        const height = document.documentElement.clientHeight

        video.setAttribute('width', width + 'px')
        video.setAttribute('height', height + 'px')

        console.log('doc xy:', width, height);


        //陀螺仪监听自动拍照
        let trigger = false
        let errCount = 0
        //初始化设备
        await deviceClass.initDevice()

        if (deviceClass.devices.length) {
          // 添加设备选择
          // deviceClass.devices.forEach(el => {
          // 	select.options.add(new Option(el.label, el.deviceId))
          // })

          console.log('devices', deviceClass.devices)

          async function selectDevice (id) {

            videoClass.stopCamera()

            // 选择设备
            const device = deviceClass.devices.find(el => el.deviceId == id)

            if (!device) return

            const deviceParams = device.getCapabilities && device.getCapabilities()

            console.log('选择设备 device', id, device, deviceParams);

            const cameraParams = {}

            if (deviceParams && deviceParams.width && deviceParams.height) {
              const MaxWidth = deviceParams.width.max > 3840 ? 3840 : deviceParams.width.max
              const MaxHeight = deviceParams.height.max > 2160 ? 2160 : deviceParams.height
                .max

              Object.assign(cameraParams, {
                width: {
                  ...deviceParams.width,
                  max: MaxWidth,
                  ideal: MaxWidth
                },
                height: {
                  ...deviceParams.height,
                  max: MaxHeight,
                  ideal: MaxHeight
                },
                frameRate: {
                  ...deviceParams.frameRate
                },
              })
            }
            // 打开摄像头
            const stream = await videoClass.startCamera(device.deviceId, cameraParams)

            console.log('video stream: ', video, stream, cameraParams);

            // 渲染视频流
            video.srcObject = stream
            // 播放
            video.play && video.play()
            video.style.display = 'block'
            // 接受捕获视频帧
            trigger = true
          }


          video.addEventListener('loadedmetadata', () => {
            const width = video.videoWidth;
            const height = video.videoHeight;
            console.log(`分辨率：${width}x${height}`);

            videoClass.initCanvas(width, height)
          });

          // 选中主摄像头
          const rootCamera = deviceClass.devices.find(el => /(主摄像头|后置相机|camera2 0)/
            .test(el.label))

          console.log('rootCamera', rootCamera, rootCamera?.label);

          if (rootCamera) {
            selectDevice(rootCamera.deviceId)
          } else {
            selectDevice(deviceClass.devices[0].deviceId)
          }

          //设备选择事件
          // select.addEventListener('change', async function(e) {
          // 	let value = select.value

          // 	selectDevice(value)
          // })

          function openTips (tip) {
            tips.innerText = tip
          }

          function goResultPage (type, data) {
            errCount = 0
            trigger = true
          }

          function goCheck () {
            videoClass.takeCamera(video).then(blob => {
              UploadCodeImage(blob).then((data) => {
                if (data.judge) {
                  openTips('识别成功！')
                  goResultPage('success', data.goodsBrand)
                } else {
                  switch (data.code) {
                    case 1000: //识别成功
                      openTips('识别成功！')
                      goResultPage('success', data.goodsBrand)
                      break;
                    case 1001: //继续识别
                      errCount = 0
                      openTips('请对准指定标签！')
                      trigger = true
                      break;
                    case 1002: //识别失败
                      errCount++
                      if (errCount == 2) {
                        errCount = 0
                        openTips('识别错误！')
                        goResultPage('error')
                      } else {
                        trigger = true
                      }
                      break;
                    default:
                      errCount = 0
                      trigger = true
                  }
                }
              })
            }).catch(err => {
              console.log('takeCamera err', err);
            })
          }

          function goRegister () {
            videoClass.takeCamera(video).then(blob => {
              RegisterCodeImage(blob, JSON.stringify({
                brandTitle: query.brandTitle,
                productTitle: query.productTitle
              })).then((data) => {
                if (data.judge) {
                  openTips('注册成功！')
                  goResultPage('register', data.goodsBrand)
                } else {
                  switch (data.code) {
                    case 1001: //继续识别
                      errCount = 0
                      openTips('请对准指定标签！')
                      trigger = true
                      break;
                    case 1002: //识别失败
                      errCount++
                      if (errCount == 2) {
                        errCount = 0
                        openTips('识别错误！')
                        goResultPage('error')
                      } else {
                        trigger = true
                      }
                      break;
                    case 1003: //已注册
                      errCount = 0
                      openTips('该标签已注册！')
                      trigger = true
                      break;
                    case 1004: //注册成功！
                      openTips('注册成功！')
                      goResultPage('register', data.goodsBrand)
                      break;
                    default:
                      errCount = 0
                      trigger = true
                  }
                }
              })
            }).catch(err => {
              console.log('takeCamera err', err);
            })
          }

          function triggerFn () {
            if (trigger) {
              //停止拍照
              trigger = false

              switch (query.source) {
                case 'check':
                  //检查
                  goCheck()
                  break;
                case 'register':
                  //检查
                  goRegister()
                  break;
              }

            }
          }

          if (gyroClass.isSport) {
            //陀螺仪监听自动拍照
            tips.innerText = '请保持稳定！'
            gyroClass.initGyro(() => {
              triggerFn()
            })
          } else {
            setInterval(() => {
              triggerFn()
            }, 1000)
          }
        } else {
          alert('该设备不支持验码！')
        }


        document.addEventListener('visibilitychange', function () {
          console.log('visibilityState', document.visibilityState);
          if (document.visibilityState === 'visible') {
            // 页面可见时的操作
            trigger = true
          } else {
            // 页面隐藏时的操作
            trigger = false
          }
          //更新状态
          openTips('请对准指定标签！')
          errCount = 0
        });

      } catch (error) {
        console.log('camera render error:', error);
      }
    });
  } catch (err) {
    console.log('err', err)
  }
</script>

</html>